package com.tjsinfo.tjsoa.system.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.json.JSONArray;
import org.json.JSONObject;

import com.tjsinfo.tjsoa.system.bo.ITSystemRolesGroupBO;
import com.tjsinfo.tjsoa.system.vo.TSystemPost;
import com.tjsinfo.tjsoa.system.vo.TSystemRolesGroup;

/**
 * 权限组查询
 * @author Administrator
 *
 */
public class RolesGroupListAction extends Action{
	private ITSystemRolesGroupBO systemRolesGroupBO;

	public ITSystemRolesGroupBO getSystemRolesGroupBO() {
		return systemRolesGroupBO;
	}

	public void setSystemRolesGroupBO(ITSystemRolesGroupBO systemRolesGroupBO) {
		this.systemRolesGroupBO = systemRolesGroupBO;
	}

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		List<TSystemRolesGroup> list;
		JSONArray array = new JSONArray();
		JSONObject object = new JSONObject();
		if (request.getParameter("start") == null) {
			list = systemRolesGroupBO.selectRolesGroupPage(0, 10);
		} else {
			Integer first = Integer.parseInt(request.getParameter("start"));
			list = systemRolesGroupBO.selectRolesGroupPage(first, 10);
		}
		Integer totalProperty = systemRolesGroupBO.selectRolesGroupTotalLine();
		object.put("totalProperty", totalProperty);
		for (TSystemRolesGroup systemRolesGroup : list) {
			JSONObject systemPostJSON = new JSONObject(systemRolesGroup);
			array.put(systemPostJSON);
		}
		object.put("root", array);
		response.getWriter().print(object);
		return null;
	}
	
	
}
